package javaweb.pojo;

import java.util.List;

/**分页对象的模型
 * @author shkstart
 * @creat -07-28 11:20
 */
public class Page<T>{
public static final Integer PAGE_SIZE=4;
private Integer pageNo;//当前页码
private Integer pageTocal;//总页码
private Integer pageSize=PAGE_SIZE;//当前显示的数量
private Integer pageTocalCount;//总记录数
    private String url;

private List<T> items;//当前页的数据

    public Page() {
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Page(Integer pageNo, Integer pageTocal, Integer pageSize, Integer pageTocalCount, String url, List<T> items) {
        this.pageNo = pageNo;
        this.pageTocal = pageTocal;
        this.pageSize = pageSize;
        this.pageTocalCount = pageTocalCount;
        this.url = url;
        this.items = items;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        if (pageNo<1){
           this.pageNo=1;
        }
       else if (pageNo>pageTocal){
            this.pageNo=pageTocal;
        } else {
           this.pageNo=pageNo;
        }
    }

    public Integer getPageTocal() {
        return pageTocal;
    }

    public void setPageTocal(Integer pageTocal) {
        this.pageTocal = pageTocal;
    }

    public Integer getPagSize() {
        return pageSize;
    }

    public void setPageSize(Integer pagSize) {
        this.pageSize = pagSize;
    }

    public Integer getPageTocalCount() {
        return pageTocalCount;
    }

    public void setPageTocalCount(Integer pageTocalCount) {
        this.pageTocalCount = pageTocalCount;
    }

    public List<T> getItems() {
        return items;
    }

    public void setItems(List<T> items) {
        this.items = items;
    }



    @Override
    public String toString() {
        return "Page{" +
                "pageNo=" + pageNo +
                ", pageTocal=" + pageTocal +
                ", pageSize=" + pageSize +
                ", pageTocalCount=" + pageTocalCount +
                ", url='" + url + '\'' +
                ", items=" + items +
                '}';
    }
}
